home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / basic / ubas830.zip / MALM.EXE / GPCFTOQ.UB < prev    next >
Text File  |  1990-08-22  |  703b  |  20 lines

  1.    10   *Gpcftoq(&Cf(),Leng1,Leng2,&A,&B,&C)
  2.    20   ' General periodic continued fraction to quadratic irrational.
  3.    30   ' Modeled on the Pascal version.
  4.    40   ' 8 May 1990
  5.    60   local H=0,Hh=1,K=1,Kk=0,P=0,Pp=1,Q=1,Qq=0,Te,I
  6.    70   for I=0 to Leng1
  7.    80   Te=P+Pp*Cf(I):P=Pp:Pp=Te
  8.    90   Te=Q+Qq*Cf(I):Q=Qq:Qq=Te
  9.   100   next I
  10.   110   for I=Leng1+1 to Leng2
  11.   120   Te=H+Cf(I)*Hh:H=Hh:Hh=Te
  12.   130   Te=K+Cf(I)*Kk:K=Kk:Kk=Te
  13.   140   next I
  14.   150   A=Q*Q*Kk+Qq*(Q*(Hh-K)-H*Qq)
  15.   160   B=P*(K*Qq-2*Q*Kk-Hh*Qq)+Pp*(Q*K-Q*Hh+2*H*Qq)
  16.   170   C=P*(P*Kk-K*Pp+Pp*Hh)-H*Pp*Pp
  17.   180   Te=gcd(A,B):Te=gcd(Te,C)
  18.   190   A=A\Te:B=B\Te:C=C\Te
  19.   200   return ' End of subroutine Gpcftoq.
  20.